-
-
Notifications
You must be signed in to change notification settings - Fork 384
feat: hmr, compare old locals to invalidate if needed #692
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@alexander-akait could you please review? Should I fix tests first (look like all of them are code snapshots) |
src/loader.js
Outdated
@@ -30,7 +38,15 @@ function hotLoader(content, context) { | |||
...context.options, | |||
locals: !!context.locals, | |||
})}); | |||
module.hot.dispose(cssReload); | |||
var _locals = ${JSON.stringify(context.locals)}; | |||
var isEqualLocals = require(${loaderUtils.stringifyRequest( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When esModule
is true it should be import
,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but previously it has
var cssReload = require(${loaderUtils.stringifyRequest(
context.context,
path.join(__dirname, 'hmr/hotModuleReplacement.js')
This should be import too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
const request = loaderUtils.stringifyRequest(context.context, modulePath); | ||
|
||
if (context.esModule) { | ||
return `import ${name} from ${request};`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexander-akait not sure if webpack module interop will work here, mb need to change to * as $name
@alexander-akait could you please review? |
@goloveychuk Sorry for delay, apparently I missed a notification somewhere 😞 , do not hesitate to ping me again, do you want to finish this? |
This PR contains a:
Motivation / Use-Case
This allows self accept css module if locals didn't changed. If changed - propagate.
Inspired by https://github.com/webpack-contrib/style-loader/blob/master/src/index.js#L231
Now new runtime is
Breaking Changes
Additional Info